Skip to main content
guest
Join
|
Help
|
Sign In
REA-Disappearance
Home
guest
|
Join
|
Help
|
Sign In
Wiki Home
Recent Changes
Pages and Files
Members
Home
Final Submissions
Readings
Casestudies
Print-Ready Templates
Online Casestudy Template
Online Reading Discussion Template
Call for Papers Proposals Exhibits
Relevant Links
linearAccuaterCode
Edit
0
1
…
0
Tags
No tags
Notify
RSS
Backlinks
Source
Print
Export (PDF)
const int motor1Pin = 4;
H-bridge leg 1 (pin 2, 1A)
const int motor2Pin = 3;
H-bridge leg 2 (pin 7, 2A)
const int enablePin = 2;
H-bridge enable pin
const int motor1Pin2 = 7;
H-bridge leg 1 (pin 2, 1A)
const int motor2Pin2 = 6;
H-bridge leg 2 (pin 7, 2A)
const int enablePin2 = 5;
H-bridge enable pin
const int motor1Pin3 = 10;
H-bridge leg 1 (pin 2, 1A)
const int motor2Pin3 = 9;
H-bridge leg 2 (pin 7, 2A)
const int enablePin3 = 8;
H-bridge enable pin
const int motor1Pin4 = 13;
H-bridge leg 1 (pin 2, 1A)
const int motor2Pin4 = 12;
H-bridge leg 2 (pin 7, 2A)
const int enablePin4 = 11;
H-bridge enable pin
const int motor1Pin5 = 24;
H-bridge leg 1 (pin 2, 1A)
const int motor2Pin5 = 23;
H-bridge leg 2 (pin 7, 2A)
const int enablePin5 = 22;
H-bridge enable pin
const int motor1Pin6 = 27;
H-bridge leg 1 (pin 2, 1A)
const int motor2Pin6 = 26;
H-bridge leg 2 (pin 7, 2A)
const int enablePin6 = 25;
H-bridge enable pin
int da = 100;
this is the delay between each actator
int din = 50;
this is the delay for how long the motors are in push. shorter means it doesn't go to full stroke
int dout = 200;
this is the delay for pulling back
int dfeedback = 100;
this is the delay before it listens again. supposedly for feedback
int audioLevel=710;
the audio limit 700 sees. to pick up everything 750 is loud claps
int minSpeed = 10;
fastest setting
int maxSpeed = 100;
slowest setting
int in = 0;
int inMin = 1023;
int inMax = 0;
int counter = 0;
void setup() {
Serial.begin(9600);
set all the other pins you're using as outputs:
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(motor2Pin2, OUTPUT);
pinMode(enablePin2, OUTPUT);
pinMode(motor1Pin3, OUTPUT);
pinMode(motor2Pin3, OUTPUT);
pinMode(enablePin3, OUTPUT);
pinMode(motor1Pin4, OUTPUT);
pinMode(motor2Pin4, OUTPUT);
pinMode(enablePin4, OUTPUT);
pinMode(motor1Pin5, OUTPUT);
pinMode(motor2Pin5, OUTPUT);
pinMode(enablePin5, OUTPUT);
pinMode(motor1Pin6, OUTPUT);
pinMode(motor2Pin6, OUTPUT);
pinMode(enablePin6 , OUTPUT);
}
void loop() {
reset min and max values every once in a while
if (counter == 9999){
counter = 0;
inMin = 1023;
inMax = 0;
}
in = analogRead(0);
Reading Sensed data from Arduino
if (in < inMin) inMin = in;
if (in > inMax) inMax = in;
Serial.println(in);
audioLevel = inMin + 400;
((inMax - inMin)/8);
audioLevel = 720;
da = minSpeed + maxSpeed - map(in, inMin, inMax, minSpeed, maxSpeed);
if(in > audioLevel)
{
digitalWrite(enablePin6, HIGH);
digitalWrite(motor1Pin6, LOW);
digitalWrite(motor2Pin6, HIGH);
delay(da);
digitalWrite(enablePin5, HIGH);
digitalWrite(motor1Pin5, LOW);
digitalWrite(motor2Pin5, HIGH);
delay(da);
digitalWrite(enablePin4, HIGH);
digitalWrite(motor1Pin4, LOW);
digitalWrite(motor2Pin4, HIGH);
delay(da);
digitalWrite(enablePin3, HIGH);
digitalWrite(motor1Pin3, LOW);
digitalWrite(motor2Pin3, HIGH);
delay(da);
digitalWrite(enablePin2, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin2, HIGH);
delay(da);
digitalWrite(enablePin, HIGH);
digitalWrite(motor1Pin, LOW);
digitalWrite(motor2Pin, HIGH);
delay(da + din);
this is where the actuators suck back in
digitalWrite(motor1Pin6, HIGH);
digitalWrite(motor2Pin6, LOW);
delay(da);
digitalWrite(motor1Pin5, HIGH);
digitalWrite(motor2Pin5, LOW);
delay(da);
digitalWrite(motor1Pin4, HIGH);
digitalWrite(motor2Pin4, LOW);
delay(da);
digitalWrite(motor1Pin3, HIGH);
digitalWrite(motor2Pin3, LOW);
delay(da);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin2, LOW);
delay(da);
digitalWrite(motor1Pin, HIGH);
digitalWrite(motor2Pin, LOW);
delay(da + din);
delay(dout);
the delay before the motors turn off
turning the motors to wait for next instruction
digitalWrite(enablePin6, LOW);
digitalWrite(enablePin5, LOW);
digitalWrite(enablePin4, LOW);
digitalWrite(enablePin3, LOW);
digitalWrite(enablePin2, LOW);
digitalWrite(enablePin, LOW);
delay to prevent feedback
delay(dfeedback);
}
else {
delay(dfeedback);
}
counter++;
}
Javascript Required
You need to enable Javascript in your browser to edit pages.
help on how to format text
Turn off "Getting Started"
Home
...
Loading...
const int motor2Pin = 3; H-bridge leg 2 (pin 7, 2A)
const int enablePin = 2; H-bridge enable pin
const int motor1Pin2 = 7; H-bridge leg 1 (pin 2, 1A)
const int motor2Pin2 = 6; H-bridge leg 2 (pin 7, 2A)
const int enablePin2 = 5; H-bridge enable pin
const int motor1Pin3 = 10; H-bridge leg 1 (pin 2, 1A)
const int motor2Pin3 = 9; H-bridge leg 2 (pin 7, 2A)
const int enablePin3 = 8; H-bridge enable pin
const int motor1Pin4 = 13; H-bridge leg 1 (pin 2, 1A)
const int motor2Pin4 = 12; H-bridge leg 2 (pin 7, 2A)
const int enablePin4 = 11; H-bridge enable pin
const int motor1Pin5 = 24; H-bridge leg 1 (pin 2, 1A)
const int motor2Pin5 = 23; H-bridge leg 2 (pin 7, 2A)
const int enablePin5 = 22; H-bridge enable pin
const int motor1Pin6 = 27; H-bridge leg 1 (pin 2, 1A)
const int motor2Pin6 = 26; H-bridge leg 2 (pin 7, 2A)
const int enablePin6 = 25; H-bridge enable pin
int da = 100; this is the delay between each actator
int din = 50; this is the delay for how long the motors are in push. shorter means it doesn't go to full stroke
int dout = 200; this is the delay for pulling back
int dfeedback = 100; this is the delay before it listens again. supposedly for feedback
int audioLevel=710; the audio limit 700 sees. to pick up everything 750 is loud claps
int minSpeed = 10; fastest setting
int maxSpeed = 100; slowest setting
int in = 0;
int inMin = 1023;
int inMax = 0;
int counter = 0;
void setup() {
Serial.begin(9600);
set all the other pins you're using as outputs:
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
pinMode(enablePin, OUTPUT);
pinMode(motor1Pin2, OUTPUT);
pinMode(motor2Pin2, OUTPUT);
pinMode(enablePin2, OUTPUT);
pinMode(motor1Pin3, OUTPUT);
pinMode(motor2Pin3, OUTPUT);
pinMode(enablePin3, OUTPUT);
pinMode(motor1Pin4, OUTPUT);
pinMode(motor2Pin4, OUTPUT);
pinMode(enablePin4, OUTPUT);
pinMode(motor1Pin5, OUTPUT);
pinMode(motor2Pin5, OUTPUT);
pinMode(enablePin5, OUTPUT);
pinMode(motor1Pin6, OUTPUT);
pinMode(motor2Pin6, OUTPUT);
pinMode(enablePin6 , OUTPUT);
}
void loop() {
reset min and max values every once in a while
if (counter == 9999){
counter = 0;
inMin = 1023;
inMax = 0;
}
in = analogRead(0); Reading Sensed data from Arduino
if (in < inMin) inMin = in;
if (in > inMax) inMax = in;
Serial.println(in);
audioLevel = inMin + 400;((inMax - inMin)/8);
audioLevel = 720;
da = minSpeed + maxSpeed - map(in, inMin, inMax, minSpeed, maxSpeed);
if(in > audioLevel)
{
digitalWrite(enablePin6, HIGH);
digitalWrite(motor1Pin6, LOW);
digitalWrite(motor2Pin6, HIGH);
delay(da);
digitalWrite(enablePin5, HIGH);
digitalWrite(motor1Pin5, LOW);
digitalWrite(motor2Pin5, HIGH);
delay(da);
digitalWrite(enablePin4, HIGH);
digitalWrite(motor1Pin4, LOW);
digitalWrite(motor2Pin4, HIGH);
delay(da);
digitalWrite(enablePin3, HIGH);
digitalWrite(motor1Pin3, LOW);
digitalWrite(motor2Pin3, HIGH);
delay(da);
digitalWrite(enablePin2, HIGH);
digitalWrite(motor1Pin2, LOW);
digitalWrite(motor2Pin2, HIGH);
delay(da);
digitalWrite(enablePin, HIGH);
digitalWrite(motor1Pin, LOW);
digitalWrite(motor2Pin, HIGH);
delay(da + din);
this is where the actuators suck back in
digitalWrite(motor1Pin6, HIGH);
digitalWrite(motor2Pin6, LOW);
delay(da);
digitalWrite(motor1Pin5, HIGH);
digitalWrite(motor2Pin5, LOW);
delay(da);
digitalWrite(motor1Pin4, HIGH);
digitalWrite(motor2Pin4, LOW);
delay(da);
digitalWrite(motor1Pin3, HIGH);
digitalWrite(motor2Pin3, LOW);
delay(da);
digitalWrite(motor1Pin2, HIGH);
digitalWrite(motor2Pin2, LOW);
delay(da);
digitalWrite(motor1Pin, HIGH);
digitalWrite(motor2Pin, LOW);
delay(da + din);
delay(dout); the delay before the motors turn off
turning the motors to wait for next instruction
digitalWrite(enablePin6, LOW);
digitalWrite(enablePin5, LOW);
digitalWrite(enablePin4, LOW);
digitalWrite(enablePin3, LOW);
digitalWrite(enablePin2, LOW);
digitalWrite(enablePin, LOW);
delay to prevent feedback
delay(dfeedback);
}
else {
delay(dfeedback);
}
counter++;
}